package com.xiaojiezhu.netty.base.protocol;

/**
 * 作者 zxj<br>
 * 时间 2017/7/14 16:10
 * 说明 协议
 */
public class CobraProtocol {
    /**
     * 协议版本：1
     */
    public final static int PROTOCOL_VERSION = 1;
    /**
     * 协议开始的标志
     */
    public final static int HEAD_DATA = 0x79;


    /**
     * 协议头
     */
    private CobraProtocolHeader header;
    /**
     * 协议内容
     */
    private byte[] content;


    public CobraProtocolHeader getHeader() {
        return header;
    }

    public void setHeader(CobraProtocolHeader header) {
        this.header = header;
    }

    public byte[] getContent() {
        return content;
    }

    public void setContent(byte[] content) {
        this.content = content;
    }

    public CobraProtocol(String contentType, byte[] content){
        CobraProtocolHeader header = new CobraProtocolHeader();
        header.setContentLength(content.length);
        header.setContentType(contentType);
        header.setVersion(PROTOCOL_VERSION);

        this.content = content;
        this.header = header;
    }

    @Override
    public String toString() {
        return "header=" + header;
    }
}
